/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package modules.legislation.datatypes;

import java.util.ArrayList;

/**
 *
 * @author Pieter Backaert
 */
public class AntennaGroup {

    private ArrayList<AntennaAndDistance> aad;
    //private AntennaAndDistance[] aad;
    //private int size;

    public AntennaGroup(){
        //aad = new AntennaAndDistance[20];
        aad = new ArrayList<AntennaAndDistance>();
        //size = -1;

    }

    public int getSize(){
        return aad.size();
    }

    public AntennaAndDistance[] getAntennaAndDistance() {
        AntennaAndDistance[] array = new AntennaAndDistance[aad.size()];
        for(int i=0 ; i<array.length ; i++)
            array[i] = aad.get(i);
        
        return array;
    }

    public AntennaAndDistance getAntennaAndDistance(int index){
        //return aad[index];
        return aad.get(index);
    }

    public void setAntennaAndDistance(int index ,AntennaAndDistance aadis ){
        //aad[index] = aadis;
        aad.set(index, aadis);
    }


    // à la ArrayList : when the array is full copy all the antenna to
    // a new array
    public void addAntennaAndDistance(AntennaAndDistance aadis ){
        aad.add(aadis);
//        size++;
//        if(size>= aad.length){
//            AntennaAndDistance[] aadNew = new  AntennaAndDistance[aad.length*2];
//
//            for(int i=0 ; i<aad.length ; i++){
//                aadNew[i] = aad[i];
//            }
//
//            //replace old one with new one
//            aad = aadNew;
//        }
//        //add the Object at the end of the array
//        aad[size]=aadis;
    }

    public void removeAntennaAndDistance(int index){
//        for(int x=index ; x<aad.length-1 ;x++){
//            aad[index] = aad[index+1];
//        }
//        size--;
        aad.remove(index);
    }
}
